/**
 * Baidu.com Inc.
 * Copyright (c) 2022 All Rights Reserved.
 */
package guaduation.utils;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Properties;

/**
 * @author wangjiajun06
 * @version 1.0
 * @description
 * @date 2022/1/17 7:25 下午
 */
public class PropertiesUtil {

    private static Properties prop = new Properties();

    /**
     * 读取配置文件
     * @param fileName
     */
    public static void readProperties(String fileName){
        try {
            InputStream in = PropertiesUtil.class.getResourceAsStream("/" + fileName);
            BufferedReader bf = new BufferedReader(new InputStreamReader(in));
            prop.load(bf);
        }catch (IOException e){
            e.printStackTrace();
        }
    }

    /**
     * 根据key读取对应的value
     * @param key
     * @return
     */
    public static String getProperty(String key){
        return prop.getProperty(key);
    }

    public static void main(String[] args) {
        PropertiesUtil.readProperties("RFIDProperties.yaml");
        System.out.println(PropertiesUtil.getProperty("url"));
    }
}
